//
//  SecondViewController.m
//  Music
//
//  Created by ExcuseMe on 17/2/23.
//  Copyright © 2017年 suyubo. All rights reserved.
//

#import "SecondViewController.h"
//1.添加头文件
#import <AVFoundation/AVFoundation.h>
@interface SecondViewController ()
//2.创建音乐播放器对象
@property(nonatomic,strong)AVAudioPlayer *myPlayer;
@end

@implementation SecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //3.音乐的播放
    //3.1 初始化播放器
    NSString *musicName=[[NSBundle mainBundle]pathForResource:@"背对背拥抱.mp3" ofType:nil];
    NSURL *musicUrl=[NSURL fileURLWithPath:musicName];
    _myPlayer=[[AVAudioPlayer alloc]initWithContentsOfURL:musicUrl error:nil];
    //3.2 播放器的基本设置
    _myPlayer.numberOfLoops=0;//无限循环
    [_myPlayer prepareToPlay];
    //3.3 进行播放
    [_myPlayer play];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
